/*
Copyright (C) <2011>  <ivan vaccari>

    <ivan.vaccari@studenti.unipr.it>


This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.


*/
#include <iostream>
#include "turingMachine.h"
#include "turingConfiguration.h"
#include "fileLoader.h"
int main(int argc,char *argv[])
{
    if (argc<2){
        std::cout<<"Usage: turing-simulator configFileName\n\nhttp://code.google.com/p/turing-simulator\nVersion 0.2 released 01-mar-2011"<<std::endl;


    }else{
        try{
            turingConfiguration cfg;
            turingMachine machine;
            fileLoader l(cfg,machine);
            if(l.loadConfigurationFromFile(argv[1])){
                machine.setPrintSeparator(false);
                std::cout<<"start computation of \""<<cfg.getName()<<"\"..."<<std::endl;
                machine.compute();
                std::cout<<"Computation finished. Final tape:"<<std::endl;
                machine.printTape();
            }
        }catch(std::string error){
            std::cout<<"Error: "<<error;
        }
    }

    return 0;
}
